home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / c-runtime / dispatch / RCS / mutex.h,v < prev    next >
Encoding:
Text File  |  1992-08-18  |  5.7 KB  |  248 lines

  1. head    1.3;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @ * @;
  6.  
  7.  
  8. 1.3
  9. date    92.08.18.04.46.58;    author dglattin;    state Exp;
  10. branches;
  11. next    1.2;
  12.  
  13. 1.2
  14. date    92.04.13.11.43.08;    author dennisg;    state Exp;
  15. branches;
  16. next    1.1;
  17.  
  18. 1.1
  19. date    91.12.09.01.07.13;    author dennisg;    state Exp;
  20. branches;
  21. next    ;
  22.  
  23.  
  24. desc
  25. @This file contains definitions and possibly implementations
  26. of a set of routines for mutual exclusion.
  27. @
  28.  
  29.  
  30. 1.3
  31. log
  32. @Saving a working version before release.
  33. @
  34. text
  35. @/* -*-c-*- */
  36.  
  37. /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
  38.  
  39. This file is part of GNU CC.
  40.  
  41. GNU CC is free software; you can redistribute it and/or modify
  42. it under the terms of the GNU General Public License as published by
  43. the Free Software Foundation; either version 2, or (at your option)
  44. any later version.
  45.  
  46. GNU CC is distributed in the hope that it will be useful,
  47. but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  49. GNU General Public License for more details.
  50.  
  51. You should have received a copy of the GNU General Public License
  52. along with GNU CC; see the file COPYING.  If not, write to
  53. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  54.  
  55. /* As a special exception, if you link this library with files
  56.    compiled with GCC to produce an executable, this does not cause
  57.    the resulting executable to be covered by the GNU General Public License.
  58.    This exception does not however invalidate any other reasons why
  59.    the executable file might be covered by the GNU General Public License.  */
  60.  
  61. /* 
  62.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/dispatch.common/RCS/mutex.h,v 1.2 1992/04/13 11:43:08 dennisg Exp dennisg $
  63.   $Author: dennisg $
  64.   $Date: 1992/04/13 11:43:08 $
  65.   $Log: mutex.h,v $
  66.  * Revision 1.2  1992/04/13  11:43:08  dennisg
  67.  * Check in after array version of run-time works.
  68.  * Expect more changes as hash version and other changes are made.
  69.  *
  70.  * Revision 1.1  1991/12/09  01:07:13  dennisg
  71.  * Initial revision
  72.  *
  73. */
  74.  
  75.  
  76. #ifndef _MUTEX_H
  77. #define _MUTEX_H
  78.  
  79. #ifdef WANT_MUTEX
  80. #if defined(NeXT)
  81. #include  <cthreads.h>
  82. #define MUTEX               mutex_t
  83. #define MUTEX_ALLOC(mutex)  { *mutex = mutex_alloc(); }
  84. #define MUTEX_INIT(mutex)   mutex_init(mutex)
  85. #define MUTEX_FREE(mutex)   mutex_free(mutex)
  86. #define MUTEX_LOCK(mutex)   mutex_lock(mutex)
  87. #define MUTEX_UNLOCK(mutex) mutex_unlock(mutex)
  88. #define MUTEX_ISLOCK(mutex)     mutex->lock /* Gak */
  89.  
  90. #elif defined(OSF)
  91.  
  92. #elif defined(mach)
  93.  
  94. #elif defined(sun)
  95. /*
  96.  * Sun lwp uses monitors.
  97.  *
  98.  * Untested.  8-Dec-91, dennisg.
  99.  */
  100. #include  <lwp/lwp.h>
  101. #include  <assert.h>
  102. #define MUTEX               (mon_t)
  103. inline MUTEX
  104. MUTEX_ALLOC(mutex) {
  105.  
  106.   MUTEX mon;
  107.   
  108.   mon_create (&mon);
  109.   return mon;
  110. }
  111. #define MUTEX_INIT(mutex)
  112. #define MUTEX_FREE(mutex)   mon_destroy(mutex)
  113. inline void
  114. MUTEX_LOCK(mutex) {
  115.  
  116.   int nestingLevel = mon_enter(mutex);
  117.   assert(nestingLevel);
  118. }
  119. #define MUTEX_UNLOCK(mutex) mon_exit(mutex)
  120. inline int
  121. MUTEX_ISLOCK(mutex) {
  122.  
  123.         thread_t        aThread;
  124.  
  125.         /* Won't work? */
  126.         return mon_waiters( mutex, &aThread, NULL, 0);
  127. }
  128.  
  129. #elif defined(COROUTINES)
  130. /*
  131.  * A environment where threads are implemented as a
  132.  *  set of coroutines.
  133.  */
  134.  
  135. #endif
  136. #endif
  137.  
  138. #ifndef MUTEX
  139. /*
  140.  * These are default mutex handler routines.
  141.  *  There is no mutex support.
  142.  *
  143.  * Let the optimizer get rid of mutexes.
  144.  */
  145.  
  146. #define MUTEX void*
  147. #define MUTEX_ALLOC(mutex)  (MUTEX)-1
  148. #define MUTEX_INIT(mutex)               (mutex)
  149. #define MUTEX_FREE(mutex)               (mutex)
  150. #define MUTEX_LOCK(mutex)               (mutex)
  151. #define MUTEX_UNLOCK(mutex)     (mutex)
  152. #define MUTEX_ISLOCK(mutex)     1
  153. #endif
  154.  
  155. #endif
  156. @
  157.  
  158.  
  159. 1.2
  160. log
  161. @Check in after array version of run-time works.
  162. Expect more changes as hash version and other changes are made.
  163. @
  164. text
  165. @d1 28
  166. a28 24
  167. /* -*-c-*-
  168.  * This file contains host specific definitions or linkage to
  169.  *  a set of mutual exclusion routines.
  170.  *
  171.  * Mutual exclusion is accomplished by a small set of 
  172.  *  definitions.  These definitions mimic Mach's mutex 
  173.  *  variables.
  174.  *
  175.  * Copyright (C) 1991 Threaded Technologies Inc.
  176.  * 
  177.  * This program is free software; you can redistribute it and/or modify
  178.  * it under the terms of the GNU General Public License as published
  179.  * by the Free Software Foundation; either version 1, or any later version.
  180.  * 
  181.  * This program is distributed in the hope that it will be useful,
  182.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  183.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  184.  * General Public License for more details.
  185.  * 
  186.  * You should receive a copy of the GNU General Public License 
  187.  * along with this program; if not, write to the Free Software
  188.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  189.  * 
  190.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/mutex.h,v 1.1 1991/12/09 01:07:13 dennisg Exp dennisg $
  191. d30 1
  192. a30 1
  193.   $Date: 1991/12/09 01:07:13 $
  194. d32 4
  195. d54 1
  196. a54 1
  197. #define    MUTEX_ISLOCK(mutex)    mutex->lock /* Gak */
  198. d89 1
  199. a89 1
  200.     thread_t    aThread;
  201. d91 2
  202. a92 2
  203.     /* Won't work? */
  204.     return mon_waiters( mutex, &aThread, NULL, 0);
  205. d114 5
  206. a118 5
  207. #define MUTEX_INIT(mutex)        (mutex)
  208. #define MUTEX_FREE(mutex)        (mutex)
  209. #define MUTEX_LOCK(mutex)        (mutex)
  210. #define MUTEX_UNLOCK(mutex)    (mutex)
  211. #define    MUTEX_ISLOCK(mutex)    1
  212. @
  213.  
  214.  
  215. 1.1
  216. log
  217. @Initial revision
  218. @
  219. text
  220. @d24 1
  221. a24 1
  222.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.c,v 0.9 1991/12/03 02:01:23 dennisg Exp dennisg $
  223. d26 5
  224. a30 2
  225.   $Date: 1991/12/03 02:01:23 $
  226.   $Log: hash.c,v $
  227. d37 1
  228. d40 2
  229. a41 2
  230. #define MUTEX               (mutex_t)
  231. #define MUTEX_ALLOC(mutex)  mutex_alloc(mutex)
  232. d46 1
  233. d78 2
  234. d81 6
  235. d93 4
  236. a96 1
  237. #else
  238. d103 2
  239. a104 1
  240. #define MUTEX (void*)
  241. d106 6
  242. a111 4
  243. #define MUTEX_INIT(mutex)
  244. #define MUTEX_FREE(mutex)
  245. #define MUTEX_LOCK(mutex)
  246. #define MUTEX_UNLOCK(mutex)
  247. @
  248.